<template>
    <div class="pages" v-if="signalsRadio1.total > 10">
        <el-pagination v-model:current-page="currentPage" v-model:page-size="pageSize" :page-sizes="[10, 15, 20, 25]"
            :small="small" :disabled="disabled" :background="background" layout="sizes, prev, pager, next"
            :total="signalsRadio1.total ? signalsRadio1.total : 100" @size-change="handleSizeChange"
            @current-change="handleCurrentChange" />
    </div>
</template>

<script setup>
import { ref } from "vue";
import { useRadio1Store } from "@/pain/search/search";
import { useCounterVip } from "@/pain/vip/index.js";
import { useCounterStore } from "@/pain/login/login.js";
import { decrypt } from "@/utils/index";
const useVip = useCounterVip();
const usdl = useCounterStore()
const signalsRadio1 = useRadio1Store();
const currentPage = ref(1);
const pageSize = ref(10);
import {userInfo} from '@/Api/api.js'
const daochu = JSON.parse(localStorage.getItem("daochu"));
const tokens = localStorage.getItem("token")
let token
if(tokens){
    userInfo().then(rex=>{
        token = rex.data.data
    })
}
const ditu = JSON.parse(localStorage.getItem("ditu"));
const handleSizeChange = (val) => {
    if (!token) {
        usdl.uselogin = true
        return
    }
    if (val > 10 && token.level_id < 2) {
        return useVip.maskShow = true
    }
    pageSize.value = val;
    let list = {
        ...daochu,
        ...ditu,
        currentPage: currentPage.value,
        pageSize: val
    };
    if (signalsRadio1.routerdetails == '1') {
        signalsRadio1.T_getsearchs(list)
    } else if (signalsRadio1.routerdetails == '2') {
        signalsRadio1.T_getsuppliers(list)
    } else if (signalsRadio1.routerdetails == '3') {
        signalsRadio1.T_getbuyers(list)
    }
};




const handleCurrentChange = (val) => {
    if (!token) {
        usdl.uselogin = true
        return
    }
    if (val > 1 && token.level_id < 2) {
        useVip.maskShow = true
        return
    }
    currentPage.value = val;
    let list = {
        ...daochu,
        ...ditu,
        currentPage: val,
        pageSize: pageSize.value
    };
    if (signalsRadio1.routerdetails == '1') {
        signalsRadio1.T_getsearchs(list)
    } else if (signalsRadio1.routerdetails == '2') {
        signalsRadio1.T_getsuppliers(list)
    } else if (signalsRadio1.routerdetails == '3') {
        signalsRadio1.T_getbuyers(list)
    }
};

// defineExpose({ currentPage , pageSize })
</script>

<style lang="scss" scoped>
.pages {
    padding: 20px;
}
</style>